# 去除列表中的重复元素,类似与set去重
def listDuplicateRemoval(old_list):
    new_list=[]
    for item in old_list:
        if item not in new_list:
            new_list.append(item)
    return new_list

def listOrderByItemAttr(old_list, attr_name, desc=False):
    # 默认为升序
    new_list = old_list
    i = 0
    while i < (len(old_list)-1):
        if getattr(old_list[i], attr_name) > getattr(old_list[i+1], attr_name):
            new_list[i], new_list[i+1] = new_list[i+1], new_list[i]    # 交换两个元素的顺序
        i += 1
    if desc is True:
        new_list.reverse()
    return new_list
